module.exports = app => {
    const { INTEGER, STRING, DATE } = app.Sequelize;
    const Doorlock = app.model.define('doorlock', {
        lockId: {
            type: STRING(50),
            primaryKey: true,
            allowNull: false,
            field: 'lock_id',
        },
        hotelId: {
            type: STRING(50),
            allowNull: false,
            field: 'hotel_id',
        },
        roomId: {
            type: STRING(50),
            allowNull: false,
            field: 'room_id',
        },
        remark: {
            type: STRING(50),
            allowNull: true,
        },
    }, {
        timestamps: true,
        paranoid: false,
        underscored: true,
        freezeTableName: true,
        getterMethods: {
            created_at() {
                return this.getDataValue('created_at') && this.getDataValue('created_at').toLocaleString();
            },
            updated_at() {
                return this.getDataValue('updated_at') && this.getDataValue('updated_at').toLocaleString();
            }
        },
    });

    return Doorlock;
}